BEGIN TRANSACTION;
BEGIN TRY
    -- 更新订单状态
    UPDATE Orders 
    SET Status = '已签收' 
    WHERE OrderID = 5001;

    -- 插入物流轨迹
    INSERT INTO LogisticsTraces (OrderID, Status, UpdateTime) 
    VALUES (5001, '已签收', GETDATE());

    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    ROLLBACK TRANSACTION;
    PRINT '状态更新失败：' + ERROR_MESSAGE();
END CATCH;
